<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="author" content="m.jd.com">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/base2013.css" charset="gbk" />
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/my.css?r=2" charset="gbk" />
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/header.css" charset="gbk" />
    <link rel="stylesheet" type="text/css"
          href="/resources/wap/css/product_list.css" charset="gbk" />
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/js/self.js?r=1"></script>
    <style type="text/css">
        .order{
            background-color: #fff;
            padding: 10px;
            border-radius: 10px;
            margin-bottom: 20px;
        }
    </style>

</head>
<body>

<header>
    <!-- 通用头 div -->
    <div id="m_common_header" style="min-height: 45px; margin-top: 0px;">
        <header class="jd-header">
            <div class="jd-header-bar">
                <div  class="jd-header-icon-back J_ping"
                      onclick="javascript:window.location.href='/html/wap/customer/cart.html'">
                    <span></span>
                </div>
                <div class="jd-header-title">
                    我的订单
                </div>
            </div>

        </header>
    </div>
</header>
<div class="common-wrapper" id="mainLayout">
    <!-- 通知中心 -->
    <div id="makeLocation" style="display:none">
        <div class="order-remind" id="orderRemind" style="display: none;">
            <div class="order-remind-flex" id="orderRemindFlex">
                <em class="order-remind-flex-pic-left"></em>
                <em class="order-remind-flex-pic-right" id="closeRemind"></em>
            </div>
        </div>
    </div>
    <!-- 通知中心 结束-->
    <div class="order-tab bdb-1px">

    </div>
    <div id="div_orderlist">
        <div id="data_list" style="position: relative; display: block;">

        </div>
        <div class="no-order" id="customerDataNote" style="display: block;">
        </div>
        <!--end if-->
    </div>
    <div id="div_ordersort" class="o-order mar9 border-1px" style="display: none;">
        <ul id="ordersort-items" class="ordersort-items">

        </ul>
    </div>
    <div class="is-loading" style="height: 35px; padding-top: 2px; display: none;">
        <em></em>
        <span>加载中...</span>
    </div>
    <span class="black-content" id="tip"></span>


</div>
</body>
<script type="text/javascript">
    var _pageFlag = false;
    var params = {
        page: 1,
        size:10
    }
    $().ready(function () {
        loadData();
    });
    function loadData(){

        $.ajax({
            url:"/wap/customer/order/queryPage.json?r="+Math.random(),
            data:params,
            dataType:'json',
            type:'post',
            success:function(data){
                if(data.success) {
                    if(data.data.data==null||data.data.data.length==0){
                        $("#data_list").html("");
                        $("#customerDataNote").html("<div class='noorder-pic' style='font-size:0.75rem;color:#bfbfbf;'>" +
                            "<span style='display:block;margin-top:20px;text-align: center;'>没有更多数据了</span></div>");
                    }else{
                        $("#data_list").html("");

                        $.each(data.data.data,function(i,order){

                            var orderNo =  order.orderNo;
                            var totalMoney = order.totalMoney;
                            var supplierName = order.supplier.name;
                            var supplierTelephone = order.supplier.telephone;
                            var orderProductHtml = "<div>";
                            var orderProducts = order.orderProducts;
                            $.each(orderProducts,function (j,op) {
                                var product = op.product;
                                var img = product.image;
                                var productName = product.name;
                                var num = op.num;
                                var norm = null2empty(op.norm);
                                var price = op.price;
                                var money = op.money;
                                var unit = null2empty(product.unit);
                                orderProductHtml = orderProductHtml+
                                    "<div class='product-list'>"+
                                        "<div class='product-image' style='background-image: url(\""+img+"\")'></div>"+
                                        "<div>" +
                                            "<div><span class='note'>产品：</span><span>"+productName+"</span></div>"+
                                            "<div><span class='note'>规格：</span><span>"+norm+"</span></div>"+
                                            "<div><span class='note'>数量：</span><span>"+num+unit+"</span></div>"+
                                            "<div><span class='note'>金额：</span><span>"+money+"</span></div>"+
                                        "</div>"+
                                    "</div>";
                            });
                            orderProductHtml = orderProductHtml+"</div>";
                            var html = "<div class='order'>"+
                                        "<div class='order-info'>" +
                                           "<div><span class='note'>订单号:</span><span>"+orderNo+"</span></div>"+
                                           "<div><span class='note'>金额:</span><span>"+totalMoney+"</span></div>"+
                                           "<div><span class='note'>供货商:</span><span>"+supplierName+"</span></div>"+
                                           "<div><span class='note'>电话:</span><span>"+supplierTelephone+"</span></div>"+

                                        "</div>"+
                                        orderProductHtml+
                                    "</div>";

                            $("#data_list").append(html);
                        });
                    }
                    if (data.data.pageNo < data.data.pageTotal) {
                        _pageFlag = true;

                    }else{
                        //  $("#customerDataNote").html("<div ><span>没有更多订单了</span></div>");
                    }
                }
            }
        });
    }
    $(window).scroll(function () {
        if (_pageFlag) {
            if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
                _pageFlag = false;
                params['page'] = params['page'] + 1;
                loadData();
            }
        }
    });
    function addProduct(id) {
        window.location.href="product_edit.html?productId="+id;
    }
</script>
</html>